﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;

namespace OpenPhotoAlbum.Controls.PhotoProcessors
{
	public class OilPainting : Offset
	{
		private Random _rn = new Random();

		public override void ConfigureOffsetMatrix(Point[,] offsetMatrix, int width, int height)
		{
			for (int y = 0; y < height; y++)
			{
				for (int x = 0; x < width; x++)
				{
					int resultX = x + _rn.Next(-5, 6) - x % 4;
					int resultY = y + _rn.Next(-5, 6) - y % 4;
					if (resultX < 0) { resultX = 0; }
					else if (resultX > width - 1) { resultX = width - 1; }
					if (resultY <= 0) { resultY = 0; }
					else if (resultY > height - 1) { resultY = height - 1; }
					offsetMatrix[y, x] = new Point(resultX, resultY);
				}
			}
		}
	}
}
